<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<?php
session_start();
if (empty($_SESSION["loginusername"])) {
    Header("Location: firstphp.php");
}
if (!empty($_SESSION["userType"])) {
    $userType = $_SESSION["userType"];
}

?>
<html>
    <head>
        <title>View Activity Records</title>
        <link rel="stylesheet" type="text/css" href="http://localhost/Eldercare/jquery/easyui.css">
        <link rel="stylesheet" type="text/css" href="http://localhost/Eldercare/jquery/icon.css">
        <script type="text/javascript" src="http://localhost/Eldercare/jquery/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="http://localhost/Eldercare/jquery/jquery.easyui.min.js"></script>
        <style type="text/css">
            #fm{
                margin:0;
                padding:10px 30px;
            }
            .ftitle{
                font-size:14px;
                font-weight:bold;
                color:#666;
                padding:5px 0;
                margin-bottom:10px;
                border-bottom:1px solid #ccc;
            }
            .fitem{
                margin-bottom:5px;
            }
            .fitem label{
                display:inline-block;
                width:80px;
            }
            .button 
            {
                background-color:beige;
                cursor:pointer; }
            </style>
            <link href="http://localhost/Eldercare/finalstyle.css" rel="stylesheet" type="text/css" media="all" />
            <script type="text/javascript">
                function doSearch() {
                    $('#dg').datagrid('load', {
                        NRIC: $('#NRIC').val(),
                        CustomerName: $('#CustomerName').val(),
                        Date: $('#Date').val(),
                        CentreLocation: $('#CentreLocation').val(),
                        ActivityId: $('#ActivityId').val()

                    });
                }
                function findAll() {
                    $('#dg').datagrid('load', {
                    });
                }
                function removeActAtt() {
                    var row = $('#dg').datagrid('getSelected');
                    if (row) {
                        $.messager.confirm('Confirm Delete Activity Attendance', 'Are you sure you want to remove this activity attendance record?', function(r) {
                            if (r) {
                                $.post('ViewActRecords/remove_act.php', {ActivityRecordID: row.ActivityRecordID}, function(result) {
                                    if (result.success) {
                                        $('#dg').datagrid('reload');	// reload the user data
                                    } else {
                                        $.messager.show({// show error message
                                            title: 'Error',
                                            msg: result.msg
                                        });
                                    }
                                }, 'json');
                            }
                        });
                    }
                }
                function postForm()
                {
                    var cat = document.getElementById("Category");
                    document.getElementById("catForm").submit();


                }
            </script>

        </head>
        <body>
            <div class="banner"></div>
        <div id="main">
            <div class="left-wrapper">
                <div class="logo">
                </div>
                <div class="menu-wrapper">
                    <div id='cssmenu' >
                        <ul>

                            <?php
                            if ($userType == "Therapy Assistant") {
                                //if TA
                                echo "<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li class='last'><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			 </ul>
			  </li>
			  <li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
		 <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
   <li class='last'><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
     
			 ";
                            } else if ($userType == "Centre Manager") {
                                echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                            } else {
                                echo "
			<li class='has-sub' class='active'><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/AttendanceHome.php'><span>Attendance Taking</span></a></li>
			 <li><a href='http://localhost/Eldercare/ViewAttendanceRecord.php'><span>View Attendance</span></a></li>
			<li><a href='http://localhost/Eldercare/BackDate.php'><span>BackDate</span></a></li>
			<li class='last'><a href='http://localhost/Eldercare/VerifyAttendance.php'><span>Verify Attendance</span></a></li>
			</ul>
			<li class='has-sub'><a href='#'><span>Profile</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Client.php'><span>Existing Client</span></a></li>
         <li><a href='http://localhost/Eldercare/WClient.php'><span>Withdrawn Client</span></a></li>
         <li><a href='http://localhost/Eldercare/User.php'><span>User</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/Centres.php'><span>Centres</span></a></li>
      </ul>
   </li>
   <li class='has-sub'><a href='http://localhost/Eldercare/ActRecords.php'><span>Activities</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/Activities.php'><span>Manage Current Activities</span></a></li>
         <li><a href='http://localhost/Eldercare/ActRecords.php'><span>Activity Recording</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ViewActRecord.php'><span>View Activity Records</span></a></li>
      </ul>
   </li>
   <li><a href='http://localhost/Eldercare/Holidays.php'><span>Holiday</span></a></li>
<li class='has-sub'><a href='#'><span>Reports</span></a>
   <ul>
   <li><a href='http://localhost/Eldercare/Reports.php'><span>Attendance Reports</span></a></li>
   <li class='last'><a href='http://localhost/Eldercare/ActReports.php'><span>Activity Reports</span></a></li>
   </ul>
   </li>
    <li class='has-sub'><a href='#'><span>Password</span></a>
      <ul>
         <li><a href='http://localhost/Eldercare/ManagePassword.php'><span>Change Passwords</span></a></li>
         <li class='last'><a href='http://localhost/Eldercare/ForgetPasswords.php'><span>Forget Password</span></a></li>
      </ul>
   </li>
			";
                            }
                            ?>
                        </ul>
                    </div>
                    <div class="clear"></div></div></div>
            <div class="content">
                <div class="content2">
                    <b style="float:right; margin: 0px 0 0 0">  <?php
                        //session_start();
                        if (!empty($_SESSION["centreName"])) {
                            $Username = $_SESSION["loginusername"];
                            $centreName = $_SESSION["centreName"];
                            echo "Welcome, " . $Username . " ! <br>" . $centreName . " Branch";
                        } else {
                            $Username = $_SESSION["loginusername"];
                            echo "Welcome, " . $Username;
                        }
                        ?>
                        <?php
                        ?>
                        <?php
//session_start();
// set timeout period in seconds
                        $inactive = 7200;
// check to see if $_SESSION['timeout'] is set
                        if (isset($_SESSION["timeout"])) {
                            $session_life = time() - $_SESSION["timeout"];
                            if ($session_life > $inactive) {
                                session_destroy();
                                Header("Location: Timeout.php");
                            }
                        }
                        $_SESSION["timeout"] = time();
                        ?>

                        <input type="submit" class="button" value="Logout" onclick="parent.location = 'logout.php'"></b>
                    </p><div class="clear"></div>
                    <div style="float:center">
                        <h3>Activities Records</h3>
                        <br>
                        <table id="dg" title="Activities Records" class="easyui-datagrid" style="width:auto;height:430px; "
                               url="ViewActRecords/get_ViewActRecords.php"
                               toolbar="#tb" pagination="true" singleSelect ="true"
                               rownumbers="true" fitColumns="true" >
                            <thead>
                                <tr>
                                    <th field="NRIC" width="50">NRIC</th>
                                    <th field="CustomerName" width="50">Name</th>
                                    <th field="Date" width="50">Date</th><?php
                        if ($userType == 'System Admin') {
                            echo "<th field='CentreName' width='50'>CentreName</th>";
                        }
                        ?>

                                    <th field="ActivityName" width="50">Activity Name</th>
                                    <th field="Category" width="50">Category</th>
                                    <th field="Performance" width="50">Performance</th>
                            <tbody style="display:none">
                            <th field ="ActivityRecordID" width="50">ActivityRecordID</th>
                            </tbody>
<?php
if ($userType != "System Admin") {
    echo "<tbody style='display:none'>
                                        <th field='CentreName' width='50'>Centre Name</th>
                                <th field='ActivityRecordID' width='50' >ActivityRecordID</th>";
} else {//if system admin
    echo "
                                        <th field='CentreName' width='50'>Centre Name</th>
                                        <tbody style='display:none'>
                                <th field='ActivityRecordID' width='50' >ActivityRecordID</th>";
}
?>
                            </tr>
                            </thead>
                        </table>
                        <div id="tb" style="padding:3px">
<?php
if ($userType != "Therapy Assistant") {
    echo"
            <a href='#' style='line-height:26px; solid #ccc' class='easyui-linkbutton' iconCls='icon-remove' plain='true' onclick='removeActAtt()'>Remove</a>";
}
?>
                            <span>NRIC:</span>
                            <input id="NRIC" name="NRIC" style="line-height:26px;border:1px solid #ccc">
                            <span>Name:</span>
                            <input id="CustomerName" name="CustomerName" style="line-height:26px;border:1px solid #ccc">
                            <span>Date:</span> 
                            <input id="Date" name="Date"style="line-height:26px;border:1px solid #ccc" type = "date">
<?php
if ($userType == "System Admin") {
    echo"<span>Centre:</span>
	<select name='CentreLocation' id = 'CentreLocation' class='empty'>
	  <option value='0'selected >Select a Centre</option>";

    mysql_connect("localhost", "root", "");
    mysql_select_db("eldercaredb");
    $centreDetail = "SELECT CentreId, CentreName FROM centre";
    $query_result = mysql_query($centreDetail);
    while ($result = mysql_fetch_assoc($query_result)) {

        echo"<option value=";
        echo $result['CentreId'];
        echo">";
        echo $result['CentreName'];
        echo"</option>";
    }

    echo"</select>";
}
?>

                            <span>Activity:</span>

<?php
mysql_connect("localhost", "root", "");
mysql_select_db("eldercaredb");

echo" <select name='ActivityId' id = 'ActivityId' class='empty'>
	  <option value='0'selected > </option>";
$act = "SELECT ActivityId, ActivityName FROM Activity ";
$query = mysql_query($act);
while ($res = mysql_fetch_array($query)) {
    echo "<option value='" . $res['ActivityId'] . "'>" . $res['ActivityName'] . "</option>";
}
echo "</select>";
?>


                            <a href="#" class="easyui-linkbutton" iconCls="icon-search" onClick="doSearch()">Search</a>
                            <a href="#" class="easyui-linkbutton" onClick="findAll()">All</a>
                        </div>
                    </div><p>
                </div>
                <div class="clear"></div></div>
        </div>
    </body> 
    <div></div>
    <div class="clear"></div>
    </div>
</html>